//
//  HLTabBarViewController.m
//  HanlinWeather
//
//  Created by 任翰林 on 17/1/13.
//  Copyright © 2017年 任翰林. All rights reserved.
//

#import "HLTabBarViewController.h"
//#import "HLHomeViewController.h"
//#import "HLNewsViewController.h"
//#import "HLMineViewController.h"
#import "HLBaseViewController.h"
#import "HLBaseNavigationController.h"
#import <Masonry.h>
@interface HLTabBarViewController ()

@end

@implementation HLTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self addChildVC];

}



- (void)addChildVC
{
    
    [self setChilldrenVCName:@"HLHomeViewController" andTitle:@"首页" andImageName:@"home" andSeletedImageName:@"homeS"];
    [self setChilldrenVCName:@"HLNewsViewController" andTitle:@"新闻" andImageName:@"news" andSeletedImageName:@"newsS"];
    [self setChilldrenVCName:@"HLMineViewController" andTitle:@"我的" andImageName:@"mine" andSeletedImageName:@"mineS"];
}


- (void)setChilldrenVCName:(NSString *)childrenVCName andTitle:(NSString *)title andImageName:(NSString *)imageName andSeletedImageName:(NSString *)seletedImageNmame
{
    id HLClass = NSClassFromString(childrenVCName);
    HLBaseViewController * childrenVC =  [[HLClass alloc]init];
    childrenVC.title = title;
    childrenVC.tabBarItem.image = [UIImage imageNamed:imageName];
    childrenVC.tabBarItem.selectedImage = [UIImage imageNamed:seletedImageNmame];

    HLBaseNavigationController * nav = [[HLBaseNavigationController alloc]initWithRootViewController:childrenVC];
    
    [self addChildViewController:nav];
    
//自定义tabBarItem
//    [self setTabBarItemWithTitle:title imagename:imageName seletedImageName:seletedImageNmame];
    
}



#pragma mark - 自定义tabBarItem
- (void)setTabBarItemWithTitle:(NSString *)title imagename:(NSString *)imageName seletedImageName:(NSString *)seletedName
{
    UIView * tabView = [[UIView alloc]init];
    [self.view addSubview:tabView];
    [tabView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.bottom.right.equalTo(@0);
        make.height.equalTo(@64);
        tabView.backgroundColor =  [UIColor yellowColor];
    }];
    
    //首页按钮
    UIButton * homeBtn = [[UIButton alloc]init];
    [tabView addSubview:homeBtn];
    [homeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(@40);
        make.centerY.equalTo(@0);
        make.top.equalTo(@10);
        make.bottom.equalTo(@-10);
    }];
    homeBtn.backgroundColor = [UIColor redColor];
    homeBtn.backgroundColor = [UIColor greenColor];
//    homeBtn setBackgroundColor:<#(UIColor * _Nullable)#>
    
    [homeBtn setTitle:@"home" forState:UIControlStateNormal];
    
    //新闻按钮
    UIButton * newsBtn = [[UIButton alloc]init];
    [tabView addSubview:newsBtn];
    [newsBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.center.equalTo(@0);
        make.top.equalTo(@10);
        make.bottom.equalTo(@-10);
//        make.width.equalTo(@44);
    }];
    newsBtn.backgroundColor = [UIColor redColor];
    [newsBtn setTitle:@"news" forState:UIControlStateNormal];
    
    //我的按钮
    UIButton * mineBtn = [[UIButton alloc]init];
    [tabView addSubview:mineBtn];
    [mineBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.equalTo(@-40);
        make.centerY.equalTo(@0);
        make.top.equalTo(@10);
        make.bottom.equalTo(@-10);
    }];
    mineBtn.backgroundColor = [UIColor redColor];
    [mineBtn setTitle:@"mine" forState:UIControlStateNormal];
    
    
    HLLog(@"%@",homeBtn);
     HLLog(@"%@",newsBtn.bounds);
     HLLog(@"%@",mineBtn.bounds);
    
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
